import 'package:flutter/material.dart';
import '../drawer/drawer.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePage createState() => _HomePage();
}

class _HomePage extends State<HomePage>
    with AutomaticKeepAliveClientMixin {

  @override
  bool get wantKeepAlive => true;

  @override
  void initState() {
    super.initState();
    print('HomePage initState');
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
        appBar: AppBar(
          //导航栏
          title: Text("首页"),
          actions: <Widget>[
            //导航栏右侧菜单
            IconButton(icon: Icon(Icons.share), onPressed: () {

            }),
            IconButton(icon: Icon(Icons.grade), onPressed: () {
              Navigator.pushNamed(context, "/favorite",
                  arguments: {'name': 'Favorite'});
            }),
          ],
        ),
        drawer: new MyDrawer(),
        body: Center(
            child: GridView.builder(
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 3,
              ),
              itemBuilder: (context, index) {
                return Container(
                  height: 80,
                  color: Colors.primaries[index % Colors.primaries.length],
                );
              },
              itemCount: 50,
            )
        )
    );
  }
}
